﻿#include "target.h"


Target::Target()
{
}


Target::Target(const Target& target)
{
    this->setDeviceName(target.getDeviceName());
    this->setIP(0, target.getLocal().ip);
    this->setPort(0, target.getLocal().port);
    this->setIP(1, target.getRemote().ip);
    this->setPort(1, target.getRemote().port);

}



// 设置设备名称
void Target::setDeviceName(QString name)
{
    this->device_name = name;

    return;
}

/* 设置IP
 * index: 0 设置local ip, 1 设置remote ip
 */
void Target::setIP(int index, QString ip)
{
    switch(index)
    {
    case 0:
        local.ip=ip;
        break;
    case 1:
        remote.ip=ip;
        break;
    default:
        break;
    }

    return;

}

/* 设置端口
 * index: 0 设置local port, 1 设置remote port
 */
void Target::setPort(int index, QString port)
{
    switch(index)
    {
    case 0:
        local.port=port;
        break;
    case 1:
        remote.port=port;
        break;
    default:
        break;
    }

    return;
}


// 获取设备名称
QString Target::getDeviceName() const
{
    return device_name;
}



// 获取本地配置
SYSTEM Target::getLocal() const
{
    return local;
}

// 获取远端配置
SYSTEM Target::getRemote() const
{
    return remote;
}



Target& Target::operator=(const Target& target)
{
    this->setDeviceName(target.getDeviceName());
    this->setIP(0, target.getLocal().ip);
    this->setPort(0, target.getLocal().port);
    this->setIP(1, target.getRemote().ip);
    this->setPort(1, target.getRemote().port);
    return *this;
}



